home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Gamer Resource Kit / Hardcore Gamer Resource Kit - Disc 3.iso / screensavers / saver17.zip / VoodooLights / Sources / cell_tp10.c < prev    next >
C/C++ Source or Header  |  1997-07-24  |  2KB  |  115 lines

  1. /*------------------------------------------------------/
  2. /                                                        /
  3. /    Copyright 1997, SΘrgio Durte <smd@di.fct.unl.pt>    /
  4. /                                                        /
  5. /------------------------------------------------------*/
  6.  
  7.  
  8. #include <stdlib.h>
  9. #include <math.h>
  10. #include <glide.h>
  11.  
  12. #include "defines.h"
  13. #include "mat.h"
  14. #include "rgb.h"
  15. #include "clip.h"
  16. #include "tex.h"
  17. #include "cam.h"
  18. #include "cell.h"
  19. #include "cell_util.h"
  20. #include "cell_tp10.h"
  21.  
  22. static Bool first_init = True ;
  23. static GrMipMapId_t tp10_texture_src ;
  24.  
  25. static void tp10_move_cell( Cell *c )
  26. {
  27.     mat_combv( dt, & c->vel, & c->pos, & c->pos ) ;
  28.     mat_combv( dt, & c->acc, & c->vel, & c->vel ) ;
  29.     mat_scalev( 0.95, & c->vel, & c->vel ) ;
  30. }
  31. static void tp10_acc_cell(Cell *c) 
  32. {
  33.     c->acc = xyz_Zero ;
  34.     if( c->age < 0.3 * c->adulthood && c->pos.z > 10.0 ) c->acc.z = -75.0 ;
  35. }
  36.  
  37. static void tp10_age_cell( Cell *c )
  38. {
  39.     Float f = 1.0 ;
  40.  
  41.     c->age += dt ;
  42.  
  43.     if( c->age < 0.3 * c->adulthood ) f = 1.06 ;
  44.     else if( c->age > 0.7 * c->adulthood ) f = 0.95 ;
  45.     
  46.     c->color.r = max( 0.0, min( 255.0, c->color.r * f )) ;
  47.     c->color.g = max( 0.0, min( 255.0, c->color.g * f )) ;
  48.     c->color.b = max( 0.0, min( 255.0, c->color.b * f )) ;
  49.  
  50.     if( c->age > c->adulthood ) c->status = DYING ;
  51. }
  52.  
  53. void tp10_set_glide_state( void )
  54. {
  55.     if( first_init ) {
  56.         first_init = False ;
  57.         tp10_texture_src = tex_InitTexture("title.3df") ;
  58.     }
  59.     
  60.     tex_SetTexSource( tp10_texture_src ) ;
  61.     guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB ) ;
  62.     guAlphaSource( GR_ALPHASOURCE_ITERATED_ALPHA );    
  63.     grAlphaBlendFunction( GR_BLEND_ONE, GR_BLEND_ONE, GR_BLEND_ONE, GR_BLEND_ZERO );
  64.  
  65. }
  66.  
  67. extern Float Time ;
  68.  
  69. Cell *ctp10_Constructor( Cell *dad )
  70. {
  71.  
  72.   Cell *c = cell_Constructor( CellType10 ) ;
  73.  
  74.  
  75.   c->pos.x = 0.0 ;
  76.   c->pos.y = 0.0 ;
  77.   c->pos.z = 200.0 ;
  78.  
  79.   c->max_speed = 65.0 ;
  80.  
  81.   c->dad = dad ;
  82.  
  83.   c->max_chld = 1 ;
  84.   c->p_chld = 0.0 ;
  85.  
  86.   c->adulthood = 15.0 ;
  87.   c->age = 0.0 ;
  88.  
  89.   c->size = 60.0 ;
  90.  
  91.   c->sparkle = 1.0 ;
  92.   c->sparkle_range = 0.0 ;
  93.   c->sparkle_min = 1.0 ;
  94.  
  95.   c->color.r = 10.0 ;
  96.   c->color.g = 10.0 ;
  97.   c->color.b = 10.0 ;
  98.   c->color.a = 255.0 ;
  99.  
  100.   c->move_cell = tp10_move_cell ;
  101.   c->acc_cell = tp10_acc_cell ; 
  102.   c->age_cell = tp10_age_cell ; 
  103.   return c ;
  104. }  
  105.     
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.     
  114.  
  115.